package level.editor.control;

import java.awt.BorderLayout;
import java.awt.Component;

import level.editor.control.main.Main;
import level.editor.control.main.MainScroll;
import level.editor.control.main.MainTabbed;
import level.editor.view.group.Item;

public abstract class Control extends Item
{

	public Control(MainTabbed tabbed)
	{
		super(new BorderLayout());
		this.tabbed = tabbed;
	}
	
	public void registerHandler()
	{
		for (Component component : tabbed.getComponents())
		{
			if (component instanceof MainScroll)
			{
				Main main = ((MainScroll) component).getMain();
				if (main.getHandler() != handler)
				{
					main.removeHandler(main.getHandler());
					main.addHandler(handler);
					tabbed.setHandler(handler);
					main.repaint();
				}
			}
		}
	}

	public Component getMain()
	{
		return tabbed.getSelectedMain();
	}
	
	protected MainTabbed tabbed;
	protected Handler handler;
}
